<template>
  <div>
    <h1>Parent count:{{count}}</h1>
    <button @click="allAddNum">让所有子组件的num全部加1</button>
    <Child1/>
    <Child2/>
  </div>
</template>

<script>
import Child1 from './Child1.vue'
import Child2 from './Child2.vue'
export default {
    name:'Parent',
    data() {
      return {
        count:0
      }
    },
    components:{
        Child1,
        Child2
    },
    methods:{
      allAddNum(){
        this.$children.forEach((vc) => {
          vc.num++
        })
      }
    }
}
</script>

<style>

</style>